package com.hcr.action;

import java.util.Iterator;
import java.util.List;


import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.hcr.model.Action;
import com.hcr.service.ActionService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
@Component("actionAction")
public class ActionAction extends ActionSupport implements ModelDriven<Action>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 2068655824109670559L;
	private Action action=new Action();
	private ActionService actionService;
	public String add(){
		this.actionService.add(action);
		return "showaction";
	}
	public String addAction(){
		return "add";
	}

	public String delete(){
		this.actionService.delete(action);
		return "showaction";
	}
	public Action getAction() {
		return action;
	}
	public void getActions(){
		List<Action> actions=this.actionService.findAll();
		ActionContext context=ActionContext.getContext();
		context.put("actions", actions);
		
		
	}
	public ActionService getActionService() {
		return actionService;
	}
	public Action getModel() {
		return this.action;
	}
	public void setAction(Action action) {
		this.action = action;
	}
	@Resource(name="actionService")
	public void setActionService(ActionService actionService) {
		this.actionService = actionService;
	}
	public String showAction(){
		this.getActions();
		return "success";
	}
	public String update(){
		this.actionService.update(action);
		return "showaction";
	}
	public String updateAction(){
		return "update";
	}
	
	
}
